<template>
	<!-- 入库单 ，出库单详情  -->
	<view class="">
		<view class="card-wrapper">
			<view class="radius shadow shadow-lg bg-white padding-sm light bg-blue">
				<view class="flex flex-wrap">
					<view class="basis-xs">
						单据编号:
					</view>
					<view class="basis-xl text-black">
						{{ mainOrder.BILLNO }}-( {{ billFrom[mainOrder.BILLFROM] }} )
					</view>
				</view>

				<view class="flex flex-wrap margin-top">
					<view class="basis-xs">
						集团:
					</view>
					<view class="basis-xl text-black">
						{{ mainOrder.GROUPNAME || '' }}
					</view>
				</view>
				<view class="flex flex-wrap margin-top">
					<view class="basis-xs">
						组织:
					</view>
					<view class="basis-xl text-black">
						{{ mainOrder.ORGNAME || '' }}
					</view>
				</view>
				<view class="flex flex-wrap margin-top">
					<view class="basis-xs">
						部门:
					</view>
					<view class="basis-xl text-black">
						{{ mainOrder.DEPTNAME || '' }}
					</view>
				</view>
				
				<view class="flex flex-wrap margin-top">
					<view class="basis-xs">
						供应商:
					</view>
					<view class="basis-xl text-black">
						{{ mainOrder.SUPPLYNAME || '' }}
					</view>
				</view>
				<view class="flex flex-wrap margin-top">
					<view class="basis-xs">
						申请人:
					</view>
					<view class="basis-xl text-black">
						{{ mainOrder.APPLYER || '' }}
					</view>
				</view>
				
				<view class="flex flex-wrap margin-top">
					<view class="basis-xs">
						仓库
					</view>
					<view class="basis-xl text-black">
						{{ mainOrder.STORENAME || '' }}
					</view>
				</view>
				
				<view class="flex flex-wrap margin-top ">
					<view class="basis-xs">
						备注: 
					</view>
					<view class="basis-xl text-black">
						{{ mainOrder.VMEMO || '' }}
					</view>
				</view>
			</view>
			<!-- 物资子表 -->
			
			<view class="radius shadow shadow-lg bg-white padding-sm margin-top sub-table" v-for="(item,index) in planList" :key="index">
				<view class="flex flex-wrap">
					<view class="basis-xs">
						物资单号
					</view>
					<view class="basis-xl text-black">
						<!-- {{ item[mid] }} -->
						{{ item.PK_MATERIAL }}
					</view>
				</view>
				<view class="flex flex-wrap margin-top">
					<view class="basis-xs">
						物资名称
					</view>
					<view class="basis-xl text-black" v-if="bstype!='M9001' ">
						{{ item.MATERIALNAME }} &emsp;|&emsp; {{ item.WNUM + ' '}} 
					</view>
					<view class="basis-xl text-black" v-if="bstype=='M9001' ">
						{{ item.MATERIALNAME }} &emsp;|&emsp; {{ item.WAITNUM }} {{ item.UNITNAME|| '' }}
					</view>
				</view>
				
				<view class="flex flex-wrap margin-top line-height-30 ">
					<view class="basis-xs ">
						入库数量
					</view>
					<view class="basis-xl text-black">
						{{ item.NNUM }}
					</view>
				</view>
				
				<view class="flex flex-wrap margin-top" >
					<view class="basis-xs ">
						仓库
					</view>
					<view class="basis-xl text-black">
						{{ item.STORENAME }}
					</view>
				</view>
				
				<view class="flex flex-wrap margin-top">
					<view class="basis-xs">
						货位 
					</view>
					<view class="basis-xl text-black">
						{{ item.STATIONNAME }}
					</view>
				</view>
				
				<view class="flex flex-wrap margin-top ">
					<view class="basis-xs">
						生产日期
					</view>
					<view class="basis-xl text-black">
						{{ item.FACTORYDATE }}
					</view>
				</view>
				
				<view class="flex flex-wrap margin-top ">
					<view class="basis-xs">
						保质期
					</view>
					<view class="basis-xl text-black">
						{{ item.EXPDATE }}
					</view>
				</view>
				
				<view class="flex flex-wrap margin-top">
					<view class="basis-xs">
						入库日期
					</view>
					<view class="basis-xl text-black">
						{{  item.INSTOCKDATE }}
					</view>
				</view>
				<!-- <view class="flex flex-wrap margin-top">
					<view class="basis-xs">
						图片上传
					</view>
					<view class="basis-xl text-black solid-bottom">
						{{ item.INPHOTO }} 
					</view>
				</view> -->
			</view>
			
			
			<view class="">
				<button class="cu-btn block bg-blue margin-tb-sm lg" @click="handelBack">
					返回
				</button>
			</view>
		</view>
		
		<w-picker
			mode="dateTime" 
			startYear="2000" 
			endYear="2050"
			step="1"
			:defaultVal="[1,1,1,1,2,5]" 
			:current="true" 
			@confirm="onConfirm" 
			ref="dateTime" 
			themeColor="#f00"
		></w-picker>
		
	</view>	
	
</template>
<script>
	import {
		mapState,
		mapMutations
	} from 'vuex'
	import wPicker from "@/components/w-picker/w-picker.vue";
	import api from '@/common/api.js';
	import utils from '@/common/util.js';
	let query = {
			"category":"ST_INAPPLY",
			"page":1,
			"rows":"50",
			"sidx":"",
			"sord":"",
			"queryJson":{},
			"userId":"",
			"account":"admin"
	}
	let _self, dateTimekey, activeIndex, VMEMO,BILLFROM ,ajaxUrl,pageTitle; 
	export default{
		computed: mapState(['userInfo']),
		data(){
			return{
				bstype:'',
				mainOrder:{},
				planList: [],
				isActiveNote:false,
				isActiveStore:false,
				mid:'',
				today:utils.getToDay(),
				dateTimekey:'',
				// activeIndex:'',
				label01: '单号', // 主表的第一个label
				billFrom:{
					0:'手工单',
					1:'申请单',
					2:'供货清单',
					3:'采购订单'
				}
			}
		},
		components: {
			wPicker
		},
		onLoad(p) {
			 // console.log(p);
			_self = this 
			this.bstype = p.t
			query.userId = _self.userInfo.UserId
			query.account = _self.userInfo.Account
			query.category = p.dbt;
			pageTitle = p.dbt == 'ST_OUTSTOCK'?'出库单':'入库单';
			let abc = JSON.parse(decodeURIComponent(p.item));
			abc.PK_STORE = '' ;
			abc.STORENAME = '' ;
			_self.mainOrder = abc
			ajaxUrl = api.apiPublic.saveInStore ;
			console.log(p.dbt);
			let queryJsonID ='PK_'+ query.category.split('_')[1];
			query.queryJson[queryJsonID] = p.id
			_self.mid = queryJsonID + '_DTL' ;
			utils.setPageTitle(pageTitle+'详情')
			_self.getDetail();
		},
		
		
		methods:{
			handelBack(){
				uni.navigateBack({})
			},
			
			getDetail(){
				console.log(query);// GetDateAfter
				utils.mShowLoading();
				let URL = api.apiPublic.getMaterList;
				this.axios({
					url: URL ,
					data: query ,
					isLoading: 1
				}).then(res=>{
					let { Result } = res ;
					_self.planList = Result.rows
				})
			}
			
		}
	}
</script>

<style scoped>
	.card-wrapper{
		padding: 26upx;
	}
	.line-height-30{
		line-height: 24px!important;
	}
	
	.sub-table-input{
		margin-top: 10upx;
	}
</style>
